#!/usr/bin/env bash

set -exuo pipefail

usage()
{
    echo "Usage: prep-for-debianish-build [python2|python3] [pyxattr|xattr]"
}

export DEBIAN_FRONTEND=noninteractive
apt-get update

common_debs='gcc make linux-libc-dev git rsync eatmydata acl attr par2'
common_debs="$common_debs duplicity rdiff-backup rsnapshot dosfstools kmod"
common_debs="$common_debs pkg-config libreadline-dev libacl1-dev"

pyver="${1:-python2}"
xattr="${2:-pyxattr}"

# dosfstools: for vfat for the (root) tests

case "$pyver" in
    python2)
        apt-get install -y \
                $common_debs \
                python2.7-dev python-fuse \
                python-"$xattr" python-tornado python-pytest \
                python-pytest-xdist pylint
        ;;
    python3)
        apt-get install -y \
                $common_debs \
                python3-dev python3-distutils python3-fuse \
                python3-"$xattr" python3-tornado python3-pytest \
                python3-pytest-xdist pylint3
        ;;
    *)
        usage 1>&2
        exit 2
        ;;
esac
